<?php
class SmsController extends Zend_Controller_Action {

    private $_WSDL_URI;

    public function init() {
        $this->_WSDL_URI = $this->view->serverUrl() . "/sms/index?wsdl";
    }

    public function indexAction() {
        ini_set("soap.wsdl_cache_enabled", 0);
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        if (isset($_GET['wsdl'])) {
            //return the WSDL
            $this->hadleWSDL();
        } else {
            //handle SOAP request
            $this->handleSOAP();
        }
    }

    private function hadleWSDL() {
        $autodiscover = new Zend_Soap_AutoDiscover();
        $autodiscover->setClass('Sms');
        $autodiscover->handle();
    }

    private function handleSOAP() {
        $soap = new Zend_Soap_Server($this->_WSDL_URI);
        $soap->setClass('Sms');
        $soap->handle();
    }
    
    public function clientmoAction() {
    	$MOId  = $_GET['moid'];
        $Telco = $_GET['telco'];
        $ServiceNum = $_GET['service']; 
        $Phone = $_GET['phone']; 
        $Syntax = $_GET['syntax']; 
        $Message = $_GET['message'];
    	$client = new Zend_Soap_Client($this->_WSDL_URI);
    	$result = $client->SendSms($MOId, $Telco, $ServiceNum, $Phone, $Syntax, $Message);
        echo '<pre>';
    	print_r ($result);
    	exit();
    }
}